﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;


namespace Services
{
    /// <summary>
    /// InstanceContextMode.Single表示当前累采用SingleTone（单类模式）来生成对象
    /// </summary>
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
    public class BookService : IBookService
    {
        List<Book> _book = new List<Book>();

        public void AddBooks(Book book)
        {
            book.BookNo = Guid.NewGuid().ToString();
            _book.Add(book);
        }


        public List<Book> GetAllBooks()
        {
            return _book;
        }

        public void RemoveBook(string bookID)
        {
            Book book = _book.Find(p => p.BookNo == bookID);
            _book.Remove(book);
        }
    }
}
